<%@ page import="com.macrosolution.exdebito.Message" %>
<%@ page iimport="grails.plugin.springsecurity.annotation.Secured" %>

<div class="modal fade" id="detail_message" tabindex="-1" role="dialog" aria-labelledby="wsw" aria-hidden="true">	
	<div class="modal-dialog">		
		<div class="modal-content">		
			<div class="modal-header ${eventInstance?.eventColor}">
        		<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        		<h4 class="modal-title" id="myModalLabel">
        			<i class="fa ${eventInstance?.eventIcon} text-muted" style=" color: white;"></i> &nbsp;&nbsp;&nbsp; ${eventInstance?.eventTitle}</h4>
      		</div>
			<div class="modal-body"> 
				<div id="message_detail">
					<dl>
					  <dt><h7>Dettagli:&nbsp;</h7>
					  <dd>
					  <g:if test="${eventInstance.message }">
					  	<h7 class="txt-color-blue ">${eventInstance.message}</h7>
					  </g:if>
					  <g:else>
					  	<h7 class="text-muted text-center"><small>Nessun commento</small></h7>
					  </g:else>
					  </dd>
					  </dt>
					</dl>
					<dl>
					
					  <div class="form-group">
					  	<b>Dal:</b>
						  	<g:formatDate format="dd-MM-yyyy" date="${eventInstance?.expire}"/>
								&nbsp;&nbsp;&nbsp;&nbsp;<b>Ore:</b>
						  	<g:formatDate format="HH:mm" date="${eventInstance?.expire}"/>
					  	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Al:</b>
						  	<g:formatDate format="dd-MM-yyyy" date="${eventInstance?.dateEnd}"/>
								&nbsp;&nbsp;&nbsp;&nbsp;<b>Ore:</b>
						  	<g:formatDate format="HH:mm" date="${eventInstance?.dateEnd}"/>
					  	</div>
					  					
					</dl>
					 <div class="form-group"><b>Inviato da:&nbsp;&nbsp;</b>
					 ${com.macrosolution.exdebito.User.findById(eventInstance.userID).username}&nbsp;&nbsp;<br><b>A:&nbsp;&nbsp;</b>
					<g:each in="${eventInstance.eventUser.toList() }" var="eventUser">							
						<i class="fa fa-user"></i>&nbsp;${com.macrosolution.exdebito.User.findById(eventUser.userId).username}&nbsp;-&nbsp;				
					</g:each>
					</div>
				<div align="right">
				<sec:ifAnyGranted roles="ROLE_ADMIN,ROLE_AMM">
<%--					<g:form action="delete_event" align="right">--%>
<%--						<input type="hidden" name="event_id" value="${eventInstance.id }">					--%>
<%--							<g:submitToRemote--%>
<%--								--%>
<%--								id="btn_delete"--%>
<%--								data-loading-text="Cancellazione..." --%>
<%--								url="[action:'delete_event']" --%>
<%--								update="[]"  --%>
<%--								class="btn btn-primary" --%>
<%--								value="${message(code: 'Cancella')}" --%>
<%--								onSuccess="successDeleteEvent(data,textStatus);loadButt('btn_delete',false)"--%>
<%--								onFailure="failureDeleteEvent(XMLHttpRequest,textStatus,errorThrown);loadButt('btn_delete',false)"--%>
<%--								onLoading="loadButt('btn_delete',true)"--%>
<%--							/>			--%>
<%--					</g:form>--%>
					<button type="button" id="btn_delete" data-loading-text="Cancellazione..." class="btn btn-primary" onclick="deleteEvent(${eventInstance.id })">Cancella
						</button>
				</sec:ifAnyGranted>
				<sec:ifNotGranted roles="ROLE_AMM">
					<sec:ifNotGranted roles="ROLE_ADMIN">
					<g:if test="${eventInstance.userID == userId}">																			
<%--						<g:form action="delete_event" align="right">					--%>
<%--							<input type="hidden" name="event_id" value="${eventInstance.id }">					--%>
<%--								<g:submitToRemote--%>
<%--									--%>
<%--									id="btn_delete"--%>
<%--									data-loading-text="Cancellazione..." --%>
<%--									url="[action:'delete_event']" --%>
<%--									update="[]"  --%>
<%--									class="btn btn-primary" --%>
<%--									value="${message(code: 'Cancella')}" --%>
<%--									onSuccess="successDeleteEvent(data,textStatus);loadButt('btn_delete',false)"--%>
<%--									onFailure="failureDeleteEvent(XMLHttpRequest,textStatus,errorThrown);loadButt('btn_delete',false)"--%>
<%--									onLoading="loadButt('btn_delete',true)"--%>
<%--								/>			--%>
<%--						</g:form>--%>
						<button type="button" id="btn_delete" data-loading-text="Cancellazione..." class="btn btn-primary" onclick="deleteEvent(${eventInstance.id })">Cancella
						</button>
						
					</g:if>
						
					</sec:ifNotGranted>														
				</sec:ifNotGranted>	
				</div>													
				</div>
			</div>
		</div>
	</div>
</div>